#if UNITY_EDITOR

using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using LitJson;
using UnityEngine;
using Sirenix.OdinInspector;
using System.Xml.Serialization;
using Pangoo.Common;
using MetaTable;
using Pangoo;

namespace CardCombine
{
    [Serializable]
    public partial class CardDetailRowWrapper : MetaTableDetailRowWrapper<CardOverview,UnityCardRow>
    {
        [LabelText("标题")]
        [ShowInInspector]
        public string Title
        {
            get
            {
                return UnityRow.Row.Title;
            }
            set
            {
                UnityRow.Row.Title = value;
                Save();
            }
        }



        [LabelText("显示的动态物体")]
        [ValueDropdown("@DynamicObjectOverview.GetUuidDropdown()")]
        [InlineButton("ToMenu", SdfIconType.EyeFill, Label = "")]
        [ShowInInspector]
        public string DynamicObjectUuid
        {
            get
            {
                return UnityRow.Row.DynamicObjectUuid;
            }
            set
            {
                UnityRow.Row.DynamicObjectUuid = value;
                UpdatePrefab();
                Save();
            }
        }

        public void ToMenu()
        {
            var objectTarget = Editor?.GetDetailWrapper(DynamicObjectUuid);
            if (objectTarget != null)
            {
                MenuWindow?.TrySelectMenuItemWithObject(objectTarget);
            }
        }



        GameObject m_Prefab;


        [ShowInInspector]
        [LabelText("资源预制体")]
        [ReadOnly]
        public GameObject Prefab
        {
            get
            {
                if (m_Prefab == null)
                {
                    m_Prefab = GameSupportEditorUtility.GetPrefabByDynamicObjectUuid(UnityRow.Row.DynamicObjectUuid);
                }
                return m_Prefab;
            }
        }

        public void UpdatePrefab()
        {
            m_Prefab = GameSupportEditorUtility.GetPrefabByDynamicObjectUuid(UnityRow.Row.DynamicObjectUuid);
        }

        [LabelText("描述")]
        [ShowInInspector]
        public string Desc
        {
            get
            {
                return UnityRow.Row.Desc;
            }
            set
            {
                UnityRow.Row.Desc = value;
                Save();
            }
        }

        [LabelText("背面标题")]
        [ShowInInspector]
        public string BackTitle
        {
            get
            {
                return UnityRow.Row.BackTitle;
            }
            set
            {
                UnityRow.Row.BackTitle = value;
                Save();
            }
        }


        [LabelText("背面描述")]
        [ShowInInspector]
        public string BackDesc
        {
            get
            {
                return UnityRow.Row.BackDesc;
            }
            set
            {
                UnityRow.Row.BackDesc = value;
                Save();
            }
        }
    }
}
#endif

